/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package com.uui.util;

import java.util.HashMap;

import oracle.sql.CLOB;

public class ResultMap<K, V> extends HashMap<K, V>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8871057270940517915L;


	@Override
	public boolean containsKey(Object key) {
		return super.containsKey(toLowerCase(key));
	}

	@SuppressWarnings("unchecked")
	private K toLowerCase(Object key) {
		if ((key != null) && (key instanceof String)) {
			key = ((String) key).toLowerCase();
		}
		return (K) key;
	}


	@Override
	public V get(Object key) {
		return super.get(toLowerCase(key));
	}

	@SuppressWarnings("unchecked")
	@Override
	public V put(Object key, Object value) {
		if ((value != null) && (value instanceof CLOB)) {
			try {
				int size = (int) ((CLOB) value).length();

				value = ((CLOB) value).getSubString(1L, size);
			} catch (Exception ex) {
				ex.printStackTrace();
			}

		}

		/*if ((value != null) && (value instanceof Date)) {
			try {
				value = DateUtil.convertGMTTimestamp(DateUtil.getDateyyyyMMddHHmmss((Date) value));
			} catch (Exception ex) {
				ex.printStackTrace();
			}

		}*/

		if (value != null) {
			return super.put(toLowerCase(key), (V) value);
		}
		return null;
	}
}